package com.atguigu.tingshu.album.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MinioConfig {

    // MINIO的配置类 用来创建minio客户端对象
    // 属性值可以从属性配置类读取
//    @Autowired
//    private MinioConstantProperties minioConstantProperties;
//    @Bean
//    public MinioClient minioClientProperties() {
//
//        return MinioClient.builder()
//                .endpoint(minioConstantProperties.getEndpointUrl())
//                .credentials(minioConstantProperties.getAccessKey(), minioConstantProperties.getSecretKey())
//                .build();
//    }

    @Bean
    public MinioClient minioClientProperties() {

        return MinioClient.builder()
                .endpoint(MinioConstantProperties.ENDPOINT_URL)
                .credentials(MinioConstantProperties.ACCESS_KEY, MinioConstantProperties.SECRET_KEY)
                .build();
    }
}
